﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Lamex.Library;
using Lamex.Interface;
using System.Diagnostics;
using Lamex.Library.CommonClass;
using System.Threading;

namespace Lamex.mNC.UI
{
    public partial class frmNC_Main : frmModuleBase
    {
        public frmNC_Main()
        {
            InitializeComponent();
            menuStrip1.Text = ModuleNames.mIE; //与AssemblyModuleEntry.ModuleName定义相同
        }
        public override MenuStrip GetModuleMenu()
        {
            return this.menuStrip1;
        }

        private void toolNC_Toolkit_Click(object sender, EventArgs e)
        {
            //
            //嵌入式
            //不带参
            //MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmExeForm(@"\\tx-fs10\tx-fs1\ima\MES\System\SourceCode\NC_Process_Version1\bin\Debug\NC_Process.exe", "NC集成工具"), sender as ToolStripMenuItem);
            MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmExeForm(@"\\Tx-fs10\tx-fs1\LAMEX\AppService\App\Lamex\NC_Process\NC_Process.exe", "NC集成工具"), sender as ToolStripMenuItem);

        }

        private void toolNC_Back_Client_Click(object sender, EventArgs e)
        {
            string exepath = @"\\tx-fs10\TX-FS1\IMA\MES\ShareFolder\MES项目记录\20181011085625334\LamexMESNCCLient\Debug\LamexMESNCClient.exe";
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = exepath;
            psi.UseShellExecute = false;
            psi.CreateNoWindow = true;
            Process.Start(psi);
        }

        private void toolNC_Back_Server_Click(object sender, EventArgs e)
        {
            string exepath = @"\\tx-fs10\TX-FS1\IMA\MES\ShareFolder\MES项目记录\20181011085625334\LamexMESNCServer\Debug\LamexMES-NC-Server.exe";
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = exepath;
            psi.UseShellExecute = false;
            psi.CreateNoWindow = true;
            Process.Start(psi);
        }

        private void menuNC_AL_Tools_Setting_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmBaseChildWinForm("NC_PN_AL_Parameter_Tools", 0, true, true), sender as ToolStripMenuItem);
        }

        private void menuNC_AL_Process_Parameter_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmBaseChildWinForm("NC_PN_AL_Parameter_Machine", 0, true, true), sender as ToolStripMenuItem);
        }

        private void menuNC_AL_Feature_Extract_Click(object sender, EventArgs e)
        {
            Common.GetCreoData.Function();
            MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmBaseChildWinForm("NC_PN_AL_FeatData_Creo", 0, false, false), sender as ToolStripMenuItem);
        }


        private void menuNC_AL_Process_Code_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(Frm_NC_CodeByOrder_Custom), sender as ToolStripMenuItem);
        }

        private void menuNC_AL_NC_Code_by_Order_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(Frm_NC_CodeByOrder), sender as ToolStripMenuItem);
        }

        private void menuNC_STLViewer_Click(object sender, EventArgs e)
        {
            //MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_StlViewer), sender as ToolStripMenuItem);
            
            string strAppPath = @"\\Tx-fs10\tx-fs1\LAMEX\NC\Tools\STL";
            //MdiTools.OpenIE(strAppPath + @"\STLView.exe");
            
            //嵌入式
            //不带参
            MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmExeForm(strAppPath + @"\STLView.exe", "STL查看"), sender as ToolStripMenuItem);
            //MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmExeForm(@"notepad.exe", "STL查看"), sender as ToolStripMenuItem);
            //MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmExeForm(@"C:\Program Files\PTC\Creo 5.0.5.0\Parametric\bin\parametric.exe", "STL查看"), sender as ToolStripMenuItem);
            //MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmExeForm(
            //    @"C:\Program Files\Common Files\eDrawings2020\eDrawings.exe", "eDrawings"), sender as ToolStripMenuItem);

            //带参，无效 
            //MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmExeForm(
            //    strAppPath + @"\STLView.exe" + ";" + strAppPath + @"\2765435390.stl", "STL查看器"), sender as ToolStripMenuItem);

            Thread.Sleep(2000);//不能少于1000ms
            SendKeys.SendWait("^a");  //Ctrl+A 组合键
            SendKeys.Send(strAppPath + @"\2765435390.stl");  //
            SendKeys.SendWait("{ENTER}");  //Alt+O 组合键
            SendKeys.SendWait("%O");  //Alt+O 组合键

            /*
            //模拟按下"ABCDEFG"
            SendKeys.SendWait("(ABCDEFG)");
            SendKeys.SendWait("{left 5}");
            SendKeys.SendWait("{h 10}");

            更多举例:
            SendKeys.SendWait("^C");  //Ctrl+C 组合键
            SendKeys.SendWait("+C");  //Shift+C 组合键
            SendKeys.SendWait("%C");  //Alt+C 组合键
            SendKeys.SendWait("+(AX)");  //Shift+A+X 组合键
            SendKeys.SendWait("+AX");  //Shift+A 组合键,之后按X键
            SendKeys.SendWait("{left 5}");  //按←键 5次
            SendKeys.SendWait("{h 10}");   //按h键 10次
            SendKeys.Send("汉字");  //模拟输入"汉字"2个字
            */

        }

        private void menuNC_DataSet_Access_Click(object sender, EventArgs e)
        {
            //因修改时间及用户字段设计不一致，不开放更新数据功能
            MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmBaseChildWinForm("NC_PROCESS_ACCESS", 0, false, true), sender as ToolStripMenuItem);
        }

        private void menuNC_AL_NC_Code_Test_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(Frm_NC_CodeByOrder_Test), sender as ToolStripMenuItem);
        }
        private void menuNC_Convert_Following_List_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_Processing_Follow), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Processing_DKSJR_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_DKSJR_Processing), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Processing_DKSTD_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_DKSTD_Processing), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Processing_PNSJR_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_PN_AL_SJR), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Processing_PNSTD_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_PN_AL_STD), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Checking_DKSJR_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_DKSJR_Checking), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Checking_DKSTD_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_DKSTD_Checking), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Checking_PNSJR_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_PN_AL_SJR), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Checking_PNSTD_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_PN_AL_STD), sender as ToolStripMenuItem);
        }

        private void menuNC_Convert_Uploading_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_Code_Releasing), sender as ToolStripMenuItem);
        }

        private void menuNC_Issue_Record_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_Issue_Follow), sender as ToolStripMenuItem);
        }

        private void menuNC_AL_NC_Scan_for_Processing_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_PN_AL_Scan_for_Processing), sender as ToolStripMenuItem);
        }

        private void menuNC_Basic_Non_Working_Day_Click(object sender, EventArgs e)
        {
            //MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmBaseChildWinForm("NC_Convert_Non_Working_Day", 0, true, false), sender as ToolStripMenuItem);
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_Convert_Non_Working_Day), sender as ToolStripMenuItem);
        }

        private void menuNC_Basic_Edge_Info_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildWebBrowse(this.MdiParent as IMdiForm, new frmBaseChildWinForm("NC_Convert_Edge_Material_Info", 0, true, false), sender as ToolStripMenuItem);
        }

        private void menuNC_CT_NC_Scan_for_Processing_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_PN_CT_Scan_for_Processing), sender as ToolStripMenuItem);
        }

        private void menuNC_PN_AL_Scan_Report_Click(object sender, EventArgs e)
        {
            MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frmNC_AL_Scan_Report), sender as ToolStripMenuItem);
        }
    }
}